import { ref, computed } from 'vue'
import { defineStore } from 'pinia'

export const useCounterStore = defineStore('counter', () => {
  const count = ref(0)
  const doubleCount = computed(() => count.value * 2)
  function increment() {
    count.value++
  }
  const code = {
    java: `public class HelloWorld {
                public static void main(String[] args) {
                    System.out.println("Hello, World!");
                }
  
                public int add(int a, int b) {
                    return a + b;
                }
  
                public void printMessage(String message) {
                    System.out.println(message);
                }
  
                public String greet(String name) {
                    return "Hello, " + name;
                }
  
                public boolean isEven(int number) {
                    return number % 2 == 0;
                }
  
                private int multiply(int a, int b) {
                    return a * b;
                }
  
                public void loopExample() {
                    for (int i = 0; i < 5; i++) {
                        System.out.println(i);
                    }
                }
            }`,

    javascript: `function helloWorld() {
                      console.log('Hello, World!');
                  }
  
                  function add(a, b) {
                      return a + b;
                  }
  
                  function printMessage(message) {
                      console.log(message);
                  }
  
                  function greet(name) {
                      return "Hello, " + name;
                  }
  
                  function isEven(number) {
                      return number % 2 === 0;
                  }
  
                  function multiply(a, b) {
                      return a * b;
                  }
  
                  function loopExample() {
                      for (let i = 0; i < 5; i++) {
                          console.log(i);
                      }
                  }`,

    python: `def hello_world():
                     print("Hello, World!")
  
                  def add(a, b):
                     return a + b
  
                  def print_message(message):
                     print(message)
  
                  def greet(name):
                     return "Hello, " + name
  
                  def is_even(number):
                     return number % 2 == 0
  
                  def multiply(a, b):
                     return a * b
  
                  def loop_example():
                     for i in range(5):
                         print(i)`,

    css: `body {
               font-family: Arial, sans-serif;
               background-color: #f0f0f0;
               margin: 0;
               padding: 0;
            }
  
            h1 {
               color: #333;
               font-size: 2rem;
            }
  
            p {
               font-size: 14px;
               line-height: 1.6;
               color: #555;
            }
  
            .container {
               display: flex;
               flex-direction: column;
               justify-content: center;
               align-items: center;
            }
  
            .button {
               padding: 10px 20px;
               background-color: #4CAF50;
               color: white;
               border: none;
               border-radius: 5px;
               cursor: pointer;
            }
  
            .button:hover {
               background-color: #45a049;
            }`,

    html: `<!DOCTYPE html>
             <html lang="en">
             <head>
                 <meta charset="UTF-8">
                 <meta name="viewport" content="width=device-width, initial-scale=1.0">
                 <title>Enhanced Hello World</title>
             </head>
             <body>
                 <h1>Hello, World!</h1>
                 <p>This is a sample HTML file with more content.</p>
                 <p>Here we demonstrate more HTML features.</p>
                 <button class="button">Click me</button>
                 <div class="container">
                     <p>This is inside a container div.</p>
                 </div>
             </body>
             </html>`,

    typescript: `function helloWorld(): void {
                        console.log("Hello, World!");
                     }
  
                     function add(a: number, b: number): number {
                        return a + b;
                     }
  
                     function printMessage(message: string): void {
                        console.log(message);
                     }
  
                     function greet(name: string): string {
                        return "Hello, " + name;
                     }
  
                     function isEven(number: number): boolean {
                        return number % 2 === 0;
                     }
  
                     function multiply(a: number, b: number): number {
                        return a * b;
                     }
  
                     function loopExample(): void {
                        for (let i = 0; i < 5; i++) {
                            console.log(i);
                        }
                     }`,

    json: `{
                 "greeting": "Hello, World!",
                 "numbers": [1, 2, 3, 4, 5],
                 "person": {
                     "name": "John",
                     "age": 30
                 },
                 "address": {
                     "street": "123 Main St",
                     "city": "Anytown",
                     "postalCode": "12345"
                 },
                 "isAdmin": true
             }`,

    xml: `<note>
               <to>Tove</to>
               <from>Jani</from>
               <heading>Hello</heading>
               <body>Hello, World!</body>
               <timestamp>2024-12-16T14:30:00</timestamp>
               <status>sent</status>
            </note>`,

    markdown: `# Hello, World!
                 This is a more detailed Markdown file.
  
                 ## Features
                 - Simple
                 - Easy to write
                 - Highly readable
  
                 ## Code Example
                 \`\`\`javascript
                 function greet() {
                     console.log("Hello, Markdown!");
                 }
                 \`\`\`
  
                 **Enjoy writing Markdown!**
  
                 ## Conclusion
                 Markdown is great for documentation and notes.`,

    sql: `CREATE TABLE users (
                  id INT PRIMARY KEY,
                  name VARCHAR(50),
                  email VARCHAR(100),
                  isActive BOOLEAN
              );
    
              INSERT INTO users (id, name, email, isActive)
              VALUES (1, 'John Doe', 'john.doe@example.com', true),
                     (2, 'Jane Smith', 'jane.smith@example.com', false);
    
              SELECT * FROM users;
    
              UPDATE users SET email = 'john.updated@example.com' WHERE id = 1;
    
              DELETE FROM users WHERE id = 2;`,
  }
  const modifiedCode = {
    java: `public class HelloWorld {
                public static void main(String[] args) {
                    System.out.println("Hello, Universe!"); // 修改了输出的内容
                }
  
                public int add(int a, int b) {
                    return a + b + 1; // 修改了加法函数，增加了 +1
                }
  
                public void printMessage(String message) {
                    System.out.println("Message: " + message); // 添加了 "Message: " 前缀
                }
  
                public String greet(String name) {
                    return "Greetings, " + name; // 修改了问候函数
                }
  
                public boolean isEven(int number) {
                    return number % 2 != 0; // 修改了偶数判断，变为奇数判断
                }
  
                private int multiply(int a, int b) {
                    return a * b * 2; // 修改了乘法函数，增加了 *2
                }
  
                public void loopExample() {
                    for (int i = 0; i < 10; i++) { // 修改了循环次数
                        System.out.println(i);
                    }
                }
            }`,

    javascript: `function helloWorld() {
                      console.log('Hello, Universe!'); // 修改了输出的内容
                  }
  
                  function add(a, b) {
                      return a + b + 1; // 修改了加法函数，增加了 +1
                  }
  
                  function printMessage(message) {
                      console.log("Message: " + message); // 添加了 "Message: " 前缀
                  }
  
                  function greet(name) {
                      return "Greetings, " + name; // 修改了问候函数
                  }
  
                  function isEven(number) {
                      return number % 2 !== 0; // 修改了偶数判断，变为奇数判断
                  }
  
                  function multiply(a, b) {
                      return a * b * 2; // 修改了乘法函数，增加了 *2
                  }
  
                  function loopExample() {
                      for (let i = 0; i < 10; i++) { // 修改了循环次数
                          console.log(i);
                      }
                  }`,

    python: `def hello_world():
                     print("Hello, Universe!") # 修改了输出的内容
  
                  def add(a, b):
                     return a + b + 1 # 修改了加法函数，增加了 +1
  
                  def print_message(message):
                     print("Message: " + message) # 添加了 "Message: " 前缀
  
                  def greet(name):
                     return "Greetings, " + name # 修改了问候函数
  
                  def is_even(number):
                     return number % 2 != 0 # 修改了偶数判断，变为奇数判断
  
                  def multiply(a, b):
                     return a * b * 2 # 修改了乘法函数，增加了 *2
  
                  def loop_example():
                     for i in range(10): # 修改了循环次数
                         print(i)`,

    css: `body {
               font-family: Arial, sans-serif;
               background-color: #e0e0e0; /* 修改了背景色 */
               margin: 0;
               padding: 0;
            }
  
            h1 {
               color: #444; /* 修改了标题的颜色 */
               font-size: 2rem;
            }
  
            p {
               font-size: 16px; /* 增加了字体大小 */
               line-height: 1.8; /* 修改了行高 */
               color: #555;
            }
  
            .container {
               display: flex;
               flex-direction: column;
               justify-content: center;
               align-items: center;
            }
  
            .button {
               padding: 12px 24px; /* 修改了按钮的大小 */
               background-color: #4CAF50;
               color: white;
               border: none;
               border-radius: 8px; /* 增加了圆角 */
               cursor: pointer;
            }
  
            .button:hover {
               background-color: #45a049;
            }`,

    html: `<!DOCTYPE html>
             <html lang="en">
             <head>
                 <meta charset="UTF-8">
                 <meta name="viewport" content="width=device-width, initial-scale=1.0">
                 <title>Enhanced Hello Universe</title> <!-- 修改了标题 -->
             </head>
             <body>
                 <h1>Hello, Universe!</h1> <!-- 修改了标题内容 -->
                 <p>This is a modified sample HTML file.</p> <!-- 修改了段落内容 -->
                 <button class="button">Click me</button>
                 <div class="container">
                     <p>This is inside a container div.</p>
                 </div>
             </body>
             </html>`,

    typescript: `function helloWorld(): void {
                        console.log("Hello, Universe!"); // 修改了输出的内容
                     }
  
                     function add(a: number, b: number): number {
                        return a + b + 1; // 修改了加法函数，增加了 +1
                     }
  
                     function printMessage(message: string): void {
                        console.log("Message: " + message); // 添加了 "Message: " 前缀
                     }
  
                     function greet(name: string): string {
                        return "Greetings, " + name; // 修改了问候函数
                     }
  
                     function isEven(number: number): boolean {
                        return number % 2 !== 0; // 修改了偶数判断，变为奇数判断
                     }
  
                     function multiply(a: number, b: number): number {
                        return a * b * 2; // 修改了乘法函数，增加了 *2
                     }
  
                     function loopExample(): void {
                        for (let i = 0; i < 10; i++) { // 修改了循环次数
                            console.log(i);
                        }
                     }`,

    json: `{
                 "greeting": "Hello, Universe!", // 修改了问候语
                 "numbers": [1, 2, 3, 4, 5],
                 "person": {
                     "name": "John",
                     "age": 31 // 修改了年龄
                 },
                 "address": {
                     "street": "123 Main St",
                     "city": "Anytown",
                     "postalCode": "54321" // 修改了邮政编码
                 },
                 "isAdmin": true
             }`,

    xml: `<note>
               <to>Tove</to>
               <from>Jani</from>
               <heading>Modified Hello Universe</heading> <!-- 修改了标题 -->
               <body>Hello, Universe!</body> <!-- 修改了内容 -->
               <timestamp>2024-12-16T14:45:00</timestamp> <!-- 修改了时间戳 -->
               <status>sent</status>
            </note>`,

    markdown: `# Hello, Universe!
                 This is a modified Markdown file.
  
                 ## Features
                 - Simple
                 - Easy to write
                 - Highly readable
  
                 ## Code Example
                 \`\`\`javascript
                 function greet() {
                     console.log("Hello, Markdown!");
                 }
                 \`\`\`
  
                 **Enjoy writing Markdown!**
  
                 ## Conclusion
                 Markdown is great for documentation and notes.`,

    sql: `CREATE TABLE users (
                  id INT PRIMARY KEY,
                  name VARCHAR(50),
                  email VARCHAR(100),
                  isActive BOOLEAN
              );
    
              INSERT INTO users (id, name, email, isActive)
              VALUES (1, 'John Doe', 'john.doe@example.com', true),
                     (2, 'Jane Smith', 'jane.smith@example.com', false);
    
              SELECT * FROM users;
    
              UPDATE users SET email = 'john.updated@example.com' WHERE id = 1;
    
              DELETE FROM users WHERE id = 2;`,
  }
  return { count, doubleCount, increment , code, modifiedCode}
})
